# -*- coding: UTF-8 -*-
# Author: Damon(wuud1)
# CreateDate: 
# Message:

from MysqlTools import MysqlTools
import os

db_config = dict(
        host="127.0.0.1",
        port=3306,
        user="root",
        passwd="123456",
        db="nissan_new",
        charset="utf8",
)
db = MysqlTools(db_config=db_config, type='dict')
img_path = '/Users/duanmengdi/Documents/nissan_new/nissan_all_img'
local_img_list = os.listdir(img_path)
print(len(local_img_list))

sql = '''select distinct trim(mid) from cars_structure_collection;'''
db_img_list = db.select_all(sql)
print(len(db_img_list))
num = 0
with open('./no_img.txt', 'w') as f:
    for i in db_img_list:
        img = i.get("trim(mid)")
        img_name = img+'.png'
        if img_name in local_img_list:
            continue
        f.write(img)
        f.write('\n')
        num += 1
print(num)
